Fire up your applications with Jetfire
RSS
Jetfire Wiki


Quick Search
»
Advanced Search »

Page History: Jetfire Code: News Item

Compare Page Revisions



« Older Revision - Back to Page History - Current Revision


Page Revision: 2009/07/29 01:47


Table of Contents [Hide/Show]


Jetfire Code: News Item

The Jetfire Code Class for News Item is shown below in the box. This class is used as a news or message service.

// N E W S ==========================================================================
// News.txt
//===================================================================================
// Copyright (C) 2009 TrackerRealm Corporation
// This file is part of Jetfire.  http://Jetfire.ca
// 
// Jetfire is open software: you can redistribute it and/or modify it under the terms of the 
// GNU General Public License as published by the Free Software Foundation, version 3 of the License.
// 
// Jetfire is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
// See the GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License along with Jetfire.  
// If not, see http://www.gnu.org/licenses.
// REMOVAL OF THIS NOTICE IS VIOLATION OF THE COPYRIGHT.
//===================================================================================
// DisplayName = "News Item";
// ToolTip = "News Item displays news items for a specific time interval.  Use Workspace to deliver news to specific teams.";
//===================================================================================
//
namespace JetfireApps 
{
	// This workflow creates News Items with an expiry date.
	// Use 'IsCurrent' to check the Expiry Date and identify if the News Item is current.
	// state ActiveTopic means that the News Item is current.
	public workflow NewsItem
	{
		// Add workflow constructor 
		public NewsItem() 
		{ 
			Tags = new List();
			enterstate Start();
			Created_Date = DateTime.Now;
			Created_By = Nexus.LoginUser.Name;
			Expiry_Date = DateTime.Today.AddYears(1);
		} 

		// Add states to the workflow  
		public Start()			{ }
		public ActiveTopic()	{ } 
		public InactiveTopic()	{ } 

		// Add Properties 
		// Use Subject as News Title
		// Use ToolTip as News Description
		// Add Expiry Date
		public bool Never_Expires
		{
			get;
			set;
		}
		public DateTime Created_Date
		{
			get;
			private set;
		}
		public plainString Created_By
		{
			get;
			private set;
		}
		public DateTime Expiry_Date
		{
			get;
			set;
		}
		public List Tags
		{
			get;
			private set;
		}
		public bool IsCurrent
		{
			get
			{
				if (Never_Expires)
					return true;
				if (DateTime.Now.Preceeds(Expiry_Date))
					return true;
				// This news item is now expired
				enterstate InactiveTopic();
				return false;
			}
		}

		// Add Command Methods 
		public void FinishEdit() : states(Start,ActiveTopic)
		{
			if (Subject == "")
				throw exception("Enter Title");
			if (ToolTip == "")
				throw exception("Enter Description");
			enterstate ActiveTopic();
		}
		public void Set_Inactive() : states(ActiveTopic)
		{
			enterstate InactiveTopic();
		} 
		public void Set_Active() : states(InactiveTopic)
		{
			enterstate ActiveTopic();
		} 
	}
}

ScrewTurn Wiki version 3.0.4.560. Some of the icons created by FamFamFam.